package com.dhq.queue;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.command.ActiveMQTextMessage;

import javax.jms.*;

public class Test {
    public static void main(String[] args) throws JMSException {
        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616");
        Connection connection = connectionFactory.createConnection();

        connection.start();
        //创建session
        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        Queue queue = session.createQueue("first queue");

        MessageProducer producer = session.createProducer(queue);

        TextMessage textMessage = session.createTextMessage("two message~");

        producer.send(textMessage);

        producer.close();
        session.close();
        connection.close();
    }
}
